package com.ruoyi.lab.controller;

import com.ruoyi.lab.domain.JacTestOutline;
import com.ruoyi.lab.domain.JacTestResult;
import com.ruoyi.lab.utils.MyTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.lab.domain.JacTestProject;
import com.ruoyi.lab.service.IJacTestProjectService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * project 提供者
 * 
 * @author ruoyi
 * @date 2021-04-06
 */
@RestController
@RequestMapping("project")
public class JacTestProjectController extends MyTool
{
	
	@Autowired
	private IJacTestProjectService jacTestProjectService;
	
	/**
	 * 查询${tableComment}
	 */
	@GetMapping("get/{id}")
	public Object get(@PathVariable("id") Long id)
	{
		HashMap<String,Object> result=new HashMap<String, Object>();

			result.put("data", jacTestProjectService.selectJacTestProjectById(id));
			result.put("msg", "success");
			result.put("code", "0");
			return result;
	}
	
	/**
	 * 查询project列表
	 */
	@GetMapping("list")
	public 	R list(JacTestOutline jacTestOutline)
	{   startPage();
		return result(jacTestProjectService.selectJacTestProjectList(jacTestOutline));
	}
	
	
	/**
	 * 新增保存project
	 */
	@PostMapping("save")
	public Map<String, String> addSave(@RequestBody Map<String, List<JacTestProject >>jacTestProject)
	{		
		return jacResultMsg(jacTestProjectService.insertJacTestProject(jacTestProject));
	}

	/**
	 * 修改保存project
	 */
	@PostMapping("update")
	public Map<String, String> editSave(@RequestBody  Map<String, List<JacTestProject >>jacTestProject)
	{		
		return jacResultMsg(jacTestProjectService.updateJacTestProject(jacTestProject));
	}
	
	/**
	 * 删除${tableComment}
	 */
	@GetMapping("remove")
	public Map<String, String> remove(String ids)
	{		
		return jacResultMsg(jacTestProjectService.deleteJacTestProjectByIds(ids));
	}

	@GetMapping("submit")
	public Map<String, String> submit(String ids)
	{
		return jacResultMsg(jacTestProjectService.submitJacTestProjectById(ids));
	}
	@GetMapping("back")
	public Map<String, String> back(String ids)
	{
		return jacResultMsg(jacTestProjectService.backJacTestProjectToCreate(ids));
	}

	/**
	 * 审核通过${tableComment}
	 */
	@PostMapping("examine")
	public Map<String, String> examine(@RequestBody Map<String, List<JacTestProject>> jacTestProject)
	{
		return jacResultMsg(jacTestProjectService.examineJacTestProjectById(jacTestProject));
	}

	/**
	 * 二次审核通过${tableComment}
	 */
/*	@GetMapping("examinenew/{id}")
	public R examinenew(@PathVariable("id") Long id)
	{
		return toAjax(jacTestProjectService.examinenewJacTestProjectById(id));
	}*/

	/**
	 * 审核失败${tableComment}
	 */
	@PostMapping("fail")
	public Map<String, String> fail(@RequestBody Map<String, List<JacTestProject>> jacTestProject)
	{
		return jacResultMsg(jacTestProjectService.failJacTestProjectById(jacTestProject));
	}

	/**
	 * 二次审核失败${tableComment}
	 */
	/*@GetMapping("failnew/{id}")
	public R failnew(@PathVariable("id") Long id)
	{
		return toAjax(jacTestProjectService.failnewJacTestProjectById(id));
	}*/

	/**
	 * 提交总体计划${tableComment}
	 */
	@PostMapping("submitall")
	public Map<String, String> submitall(@RequestBody List<JacTestProject> jacTestProjectList)
	{
		return jacResultMsg(jacTestProjectService.submitSelectedJacTestProjectById(jacTestProjectList));
	}

	/**
	 * 审核总体计划通过${tableComment}
	 */
/*	@PostMapping("examineall")
	public R examineall(@RequestBody JacTestProject jacTestProject)
	{
		return toAjax(jacTestProjectService.examineallJacTestProjectById(jacTestProject));
	}*/

	/**
	 * 结果审核通过${tableComment}
	 */
	@PostMapping("examineresult")
	public Map<String, String> examineresult(@RequestBody Map<String, List<JacTestProject>> jacTestProject)
	{
		return jacResultMsg(jacTestProjectService.examineResultJacTestProjectById(jacTestProject));
	}
	/**
	 * 结果审核失败${tableComment}
	 */
	@PostMapping("failresult")
	public Map<String, String> failresult(@RequestBody Map<String, List<JacTestProject>> jacTestProject)
	{
		return jacResultMsg(jacTestProjectService.failResultJacTestProjectById(jacTestProject));
	}
	@PostMapping("supplierexamine")
	public Map<String, String> supplierexamine(@RequestBody Map<String, List<JacTestProject>> jacTestProject)
	{
		return jacResultMsg(jacTestProjectService.supplierExamineJacTestProjectById(jacTestProject));
	}
	/**
	 * 结果审核失败${tableComment}
	 */
	@PostMapping("supplierfail")
	public Map<String, String> supplierfail(@RequestBody Map<String, List<JacTestProject>> jacTestProject)
	{
		return jacResultMsg(jacTestProjectService.supplierFailJacTestProjectById(jacTestProject));
	}
	@PostMapping("updateexperimentstage")
	public Map<String, String> updateexperimentstage(@RequestBody Map<String, List<JacTestProject>> jacTestProject)
	{
		return jacResultMsg(jacTestProjectService.updateJacTestProjectExperimentStage(jacTestProject));
	}


}
